package g2.routemaster.gui.wizards;

import g2.routemaster.gui.BoardSingleton;
import g2.routemaster.gui.GManager;
import g2.routemaster.model.Board;
import g2.routemaster.model.CityCard;
import g2.routemaster.model.GameManager;
import g2.routemaster.model.Player;

import org.eclipse.jface.wizard.Wizard;

public class PlayCardWizard extends Wizard {
   protected boolean isCompleted = false;
   CityCard card;
   boolean isFirst = true;
   boolean clearBoard = false;
   Player player;
   
   public PlayCardWizard() {
      super();
      setWindowTitle("Play Card");
   }
   
   public void addPages() {
      PlayCardPage newPage = new PlayCardPage();
      addPage(newPage);
   }
   
   public boolean canFinish(){
      return isCompleted;
   }
   
   public boolean performFinish() {
      GameManager gm = GManager.instance().getGameManager();
      Board board = gm.getBoard();
      Player player = gm.getTurnManager().getPlayer();
      if(clearBoard){
         gm.getTurnManager().discardPlayedStack();
      } else {
         board.placeCardOnBoard(player, card, isFirst);
      }
      BoardSingleton.instance().updateAll();
      return true;
   }
   
   public void setPlayer(Player player){
      this.player = player;
   }
}
